home *** CD-ROM | disk | FTP | other *** search
/ Aminet 19 / Aminet 19 (1997)(GTI - Schatztruhe)[!][Jun 1997].iso / Aminet / dev / mui / MUIPlusPlus.lha / Source / MainHeader / HeaderEnd < prev    next >
Encoding:
Text File  |  1997-03-24  |  12.1 KB  |  578 lines

  1. /***************************************************************************
  2. **                  CMUI_HGroup class definition
  3. ***************************************************************************/
  4.  
  5. class CMUI_HGroup : public CMUI_Group
  6. {
  7. public:
  8.  
  9.     CMUI_HGroup (void)
  10.     : CMUI_Group ()
  11.     {
  12.         object = NULL;
  13.     }
  14.  
  15.     CMUI_HGroup (Tag tag1, ...)
  16.     : CMUI_Group (MUIA_Group_Horiz, TRUE,
  17.                   TAG_MORE, (Tag)&tag1)
  18.     {
  19.     }
  20.  
  21.     CMUI_HGroup (Object * obj)
  22.     : CMUI_Group ()
  23.     {
  24.         object = obj;
  25.     }
  26. };
  27.  
  28. inline CMUI_String::operator const char * ()
  29. {
  30.     return (const char *)Contents ();
  31. }
  32.  
  33. inline CMUI_String::operator ULONG ()
  34. {
  35.     return Integer ();
  36. }
  37.  
  38. inline CMUI_String & CMUI_String::operator = (const char *contents)
  39. {
  40.     SetContents ((STRPTR)contents);
  41.     return *this;
  42. }
  43.  
  44. inline CMUI_String & CMUI_String::operator = (ULONG contents)
  45. {
  46.     SetInteger (contents);
  47.     return *this;
  48. }
  49.  
  50. inline CMUI_Text::operator const char * ()
  51. {
  52.     return (const char *)Contents ();
  53. }
  54.  
  55. inline CMUI_Text & CMUI_Text::operator = (const char *contents)
  56. {
  57.     SetContents ((STRPTR)contents);
  58.     return *this;
  59. }
  60.  
  61. inline CMUI_Numeric::operator LONG ()
  62. {
  63.     return Value ();
  64. }
  65.  
  66. inline CMUI_Numeric::operator int ()
  67. {
  68.     return (int)Value ();
  69. }
  70.  
  71. inline CMUI_Numeric & CMUI_Numeric::operator = (LONG value)
  72. {
  73.     SetValue (value);
  74.     return *this;
  75. }
  76.  
  77. inline CMUI_Numeric & CMUI_Numeric::operator = (int value)
  78. {
  79.     SetValue ((LONG)value);
  80.     return *this;
  81. }
  82.  
  83. inline CMUI_Numeric CMUI_Numeric::operator ++ ()            // prefix
  84. {
  85.     Increase (1);
  86.     return *this;
  87. }
  88.  
  89. inline CMUI_Numeric CMUI_Numeric::operator ++ (int dummy)   // postfix
  90. {
  91.     Increase (1);
  92.     return *this;
  93. }
  94.  
  95. inline CMUI_Numeric & CMUI_Numeric::operator += (LONG value)
  96. {
  97.     Increase (value);
  98.     return *this;
  99. }
  100.  
  101. inline CMUI_Numeric CMUI_Numeric::operator -- ()            // prefix
  102. {
  103.     Decrease (1);
  104.     return *this;
  105. }
  106.  
  107. inline CMUI_Numeric CMUI_Numeric::operator -- (int dummy)   // postfix
  108. {
  109.     Decrease (1);
  110.     return *this;
  111. }
  112.  
  113. inline CMUI_Numeric & CMUI_Numeric::operator -= (LONG value)
  114. {
  115.     Decrease (value);
  116.     return *this;
  117. }
  118.  
  119. #ifdef MUIPP_TEMPLATES
  120.  
  121. /***************************************************************************
  122. **        CTMUI_List : Template version of CMUI_List class definition
  123. ***************************************************************************/
  124.  
  125. template <class Type>
  126. class CTMUI_List : public CMUI_Area
  127. {
  128. public:
  129.     CTMUI_List (void)
  130.     : CMUI_Area ()
  131.     {
  132.         object = NULL;
  133.     }
  134.  
  135.     CTMUI_List (Tag tag1, ...)
  136.     : CMUI_Area ()
  137.     {
  138.         object = MUI_NewObjectA (MUIC_List, (struct TagItem *)&tag1);
  139. #ifdef MUIPP_DEBUG
  140.         if (object == NULL)
  141.             _MUIPPWarning ("Could not create a CTMUI_List object\n");
  142. #endif
  143.     }
  144.  
  145.     CTMUI_List (Object * obj)
  146.     : CMUI_Area ()
  147.     {
  148.         object = obj;
  149.     }
  150.  
  151.     CTMUI_List & operator = (Object * obj)
  152.     {
  153.         object = obj;
  154.         return *this;
  155.     }
  156.  
  157.     // By overloading the [] operator you can treat lists like arrays
  158.  
  159.     Type & operator [] (LONG pos)
  160.     {
  161.         Type *entry;
  162.         DoMethod (MUIM_List_GetEntry, pos, &entry);
  163.  
  164. #ifdef MUIPP_DEBUG
  165.         if (entry == NULL)
  166.             _MUIPPError ("Index into CTMUI_List is out of range:\n"
  167.                          "Index = %ld, List length = %ld\n", pos, (LONG)Entries());
  168. #endif
  169.         return *entry;
  170.     }
  171.  
  172.     // This method is a convienient alternative to the Entries attribute
  173.  
  174.     LONG Length (void) const
  175.     {
  176.         return (LONG)GetAttr (MUIA_List_Entries);
  177.     }
  178.  
  179.     // This method can be used to retrieve the number of selected entries
  180.     // in a list
  181.  
  182.     ULONG NumSelected (void)
  183.     {
  184.         ULONG numSelected;
  185.         DoMethod (MUIM_List_Select, MUIV_List_Select_All, MUIV_List_Select_Ask, &numSelected);
  186.         return numSelected;
  187.     }
  188.  
  189.     // These methods can be used as shortcuts for inserting objects into lists
  190.  
  191.     void InsertTop (Type *entry)
  192.     {
  193.         DoMethod (MUIM_List_InsertSingle, entry, MUIV_List_Insert_Top);
  194.     }
  195.  
  196.     void InsertTop (Type &entry)
  197.     {
  198.         DoMethod (MUIM_List_InsertSingle, &entry, MUIV_List_Insert_Top);
  199.     }
  200.  
  201.     void InsertBottom (Type *entry)
  202.     {
  203.         DoMethod (MUIM_List_InsertSingle, entry, MUIV_List_Insert_Bottom);
  204.     }
  205.  
  206.     void InsertBottom (Type &entry)
  207.     {
  208.         DoMethod (MUIM_List_InsertSingle, &entry, MUIV_List_Insert_Bottom);
  209.     }
  210.  
  211.     void InsertSorted (Type *entry)
  212.     {
  213.         DoMethod (MUIM_List_InsertSingle, entry, MUIV_List_Insert_Sorted);
  214.     }
  215.  
  216.     void InsertSorted (Type &entry)
  217.     {
  218.         DoMethod (MUIM_List_InsertSingle, &entry, MUIV_List_Insert_Sorted);
  219.     }
  220.  
  221.     void InsertActive (Type *entry)
  222.     {
  223.         DoMethod (MUIM_List_InsertSingle, entry, MUIV_List_Insert_Active);
  224.     }
  225.  
  226.     void InsertActive (Type &entry)
  227.     {
  228.         DoMethod (MUIM_List_InsertSingle, &entry, MUIV_List_Insert_Active);
  229.     }
  230.  
  231.     void InsertSingle (Type &entry, LONG pos)
  232.     {
  233.         DoMethod (MUIM_List_InsertSingle, &entry, pos);
  234.     }
  235.  
  236.     LONG Active (void) const
  237.     {
  238.          return (LONG)GetAttr (MUIA_List_Active);
  239.     }
  240.  
  241.     void SetActive (LONG value)
  242.     {
  243.          SetAttr (MUIA_List_Active, (ULONG)value);
  244.     }
  245.  
  246.     BOOL AutoVisible (void) const
  247.     {
  248.          return (BOOL)GetAttr (MUIA_List_AutoVisible);
  249.     }
  250.  
  251.     void SetAutoVisible (BOOL value)
  252.     {
  253.          SetAttr (MUIA_List_AutoVisible, (ULONG)value);
  254.     }
  255.  
  256.     void SetCompareHook (struct Hook * value)
  257.     {
  258.          SetAttr (MUIA_List_CompareHook, (ULONG)value);
  259.     }
  260.  
  261.     void SetConstructHook (struct Hook * value)
  262.     {
  263.          SetAttr (MUIA_List_ConstructHook, (ULONG)value);
  264.     }
  265.  
  266.     void SetDestructHook (struct Hook * value)
  267.     {
  268.          SetAttr (MUIA_List_DestructHook, (ULONG)value);
  269.     }
  270.  
  271.     void SetDisplayHook (struct Hook * value)
  272.     {
  273.          SetAttr (MUIA_List_DisplayHook, (ULONG)value);
  274.     }
  275.  
  276.     BOOL DragSortable (void) const
  277.     {
  278.          return (BOOL)GetAttr (MUIA_List_DragSortable);
  279.     }
  280.  
  281.     void SetDragSortable (BOOL value)
  282.     {
  283.          SetAttr (MUIA_List_DragSortable, (ULONG)value);
  284.     }
  285.  
  286.     LONG DropMark (void) const
  287.     {
  288.          return (LONG)GetAttr (MUIA_List_DropMark);
  289.     }
  290.  
  291.     LONG Entries (void) const
  292.     {
  293.          return (LONG)GetAttr (MUIA_List_Entries);
  294.     }
  295.  
  296.     LONG First (void) const
  297.     {
  298.          return (LONG)GetAttr (MUIA_List_First);
  299.     }
  300.  
  301.     STRPTR Format (void) const
  302.     {
  303.          return (STRPTR)GetAttr (MUIA_List_Format);
  304.     }
  305.  
  306.     void SetFormat (STRPTR value)
  307.     {
  308.          SetAttr (MUIA_List_Format, (ULONG)value);
  309.     }
  310.  
  311.     LONG InsertPosition (void) const
  312.     {
  313.          return (LONG)GetAttr (MUIA_List_InsertPosition);
  314.     }
  315.  
  316.     void SetMultiTestHook (struct Hook * value)
  317.     {
  318.          SetAttr (MUIA_List_MultiTestHook, (ULONG)value);
  319.     }
  320.  
  321.     void SetQuiet (BOOL value)
  322.     {
  323.          SetAttr (MUIA_List_Quiet, (ULONG)value);
  324.     }
  325.  
  326.     BOOL ShowDropMarks (void) const
  327.     {
  328.          return (BOOL)GetAttr (MUIA_List_ShowDropMarks);
  329.     }
  330.  
  331.     void SetShowDropMarks (BOOL value)
  332.     {
  333.          SetAttr (MUIA_List_ShowDropMarks, (ULONG)value);
  334.     }
  335.  
  336.     char * Title (void) const
  337.     {
  338.          return (char *)GetAttr (MUIA_List_Title);
  339.     }
  340.  
  341.     void SetTitle (char * value)
  342.     {
  343.          SetAttr (MUIA_List_Title, (ULONG)value);
  344.     }
  345.  
  346.     LONG Visible (void) const
  347.     {
  348.          return (LONG)GetAttr (MUIA_List_Visible);
  349.     }
  350.  
  351.     ULONG Clear (void)
  352.     {
  353.         return DoMethod (MUIM_List_Clear);
  354.     }
  355.  
  356.     ULONG CreateImage (Object * obj, ULONG flags)
  357.     {
  358.         return DoMethod (MUIM_List_CreateImage, obj, flags);
  359.     }
  360.  
  361.     ULONG DeleteImage (APTR listimg)
  362.     {
  363.         return DoMethod (MUIM_List_DeleteImage, listimg);
  364.     }
  365.  
  366.     ULONG Exchange (LONG pos1, LONG pos2)
  367.     {
  368.         return DoMethod (MUIM_List_Exchange, pos1, pos2);
  369.     }
  370.  
  371.     ULONG GetEntry (LONG pos, Type ** entry)
  372.     {
  373.         return DoMethod (MUIM_List_GetEntry, pos, entry);
  374.     }
  375.  
  376.     ULONG Insert (Type ** entries, LONG count, LONG pos)
  377.     {
  378.         return DoMethod (MUIM_List_Insert, entries, count, pos);
  379.     }
  380.  
  381.     ULONG InsertSingle (Type * entry, LONG pos)
  382.     {
  383.         return DoMethod (MUIM_List_InsertSingle, entry, pos);
  384.     }
  385.  
  386.     ULONG Jump (LONG pos)
  387.     {
  388.         return DoMethod (MUIM_List_Jump, pos);
  389.     }
  390.  
  391.     ULONG Move (LONG from, LONG to)
  392.     {
  393.         return DoMethod (MUIM_List_Move, from, to);
  394.     }
  395.  
  396.     ULONG NextSelected (LONG * pos)
  397.     {
  398.         return DoMethod (MUIM_List_NextSelected, pos);
  399.     }
  400.  
  401.     ULONG Redraw (LONG pos)
  402.     {
  403.         return DoMethod (MUIM_List_Redraw, pos);
  404.     }
  405.  
  406.     ULONG Remove (LONG pos)
  407.     {
  408.         return DoMethod (MUIM_List_Remove, pos);
  409.     }
  410.  
  411.     ULONG Select (LONG pos, LONG seltype, LONG * state)
  412.     {
  413.         return DoMethod (MUIM_List_Select, pos, seltype, state);
  414.     }
  415.  
  416.     ULONG Sort (void)
  417.     {
  418.         return DoMethod (MUIM_List_Sort);
  419.     }
  420.  
  421.     ULONG TestPos (LONG x, LONG y, struct MUI_List_TestPos_Result * res)
  422.     {
  423.         return DoMethod (MUIM_List_TestPos, x, y, res);
  424.     }
  425. };
  426.  
  427.  
  428.  
  429. /***************************************************************************
  430. **  CTMUI_Listview : Template version of CMUI_Listview class definition
  431. ***************************************************************************/
  432.  
  433. template <class Type>
  434. class CTMUI_Listview : public CTMUI_List<Type>
  435. {
  436. public:
  437.     CTMUI_Listview (void)
  438.     : CTMUI_List<Type> ()
  439.     {
  440.         object = NULL;
  441.     }
  442.  
  443.     CTMUI_Listview (Tag tag1, ...)
  444.     : CTMUI_List<Type> ()
  445.     {
  446. #ifdef MUIPP_DEBUG
  447.         _CheckTagsSpecified ("CTMUI_Listview", (struct TagItem *)&tag1, MUIA_Listview_List, "MUIA_Listview_List", TAG_DONE);
  448. #endif
  449.         object = MUI_NewObjectA (MUIC_Listview, (struct TagItem *)&tag1);
  450. #ifdef MUIPP_DEBUG
  451.         if (object == NULL)
  452.             _MUIPPWarning ("Could not create a CTMUI_Listview object\n");
  453. #endif
  454.     }
  455.  
  456.     CTMUI_Listview (Object * obj)
  457.     : CTMUI_List<Type> ()
  458.     {
  459.         object = obj;
  460.     }
  461.  
  462.     CTMUI_Listview & operator = (Object * obj)
  463.     {
  464.         object = obj;
  465.         return *this;
  466.     }
  467.  
  468.     LONG ActivePage (void) const
  469.     {
  470.          return (LONG)GetAttr (MUIA_Group_ActivePage);
  471.     }
  472.  
  473.     void SetActivePage (LONG value)
  474.     {
  475.          SetAttr (MUIA_Group_ActivePage, (ULONG)value);
  476.     }
  477.  
  478.     struct List * ChildList (void) const
  479.     {
  480.          return (struct List *)GetAttr (MUIA_Group_ChildList);
  481.     }
  482.  
  483.     void SetColumns (LONG value)
  484.     {
  485.          SetAttr (MUIA_Group_Columns, (ULONG)value);
  486.     }
  487.  
  488.     LONG HorizSpacing (void) const
  489.     {
  490.          return (LONG)GetAttr (MUIA_Group_HorizSpacing);
  491.     }
  492.  
  493.     void SetHorizSpacing (LONG value)
  494.     {
  495.          SetAttr (MUIA_Group_HorizSpacing, (ULONG)value);
  496.     }
  497.  
  498.     void SetRows (LONG value)
  499.     {
  500.          SetAttr (MUIA_Group_Rows, (ULONG)value);
  501.     }
  502.  
  503.     void SetSpacing (LONG value)
  504.     {
  505.          SetAttr (MUIA_Group_Spacing, (ULONG)value);
  506.     }
  507.  
  508.     LONG VertSpacing (void) const
  509.     {
  510.          return (LONG)GetAttr (MUIA_Group_VertSpacing);
  511.     }
  512.  
  513.     void SetVertSpacing (LONG value)
  514.     {
  515.          SetAttr (MUIA_Group_VertSpacing, (ULONG)value);
  516.     }
  517.  
  518.     ULONG ExitChange (void)
  519.     {
  520.         return DoMethod (MUIM_Group_ExitChange);
  521.     }
  522.  
  523.     ULONG InitChange (void)
  524.     {
  525.         return DoMethod (MUIM_Group_InitChange);
  526.     }
  527.  
  528.     ULONG Sort (StartVarArgs sva, Object * obj, ...)
  529.     {
  530.         sva.methodID = MUIM_Group_Sort;
  531.         return DoMethodA ((Msg)&sva);
  532.     }
  533.  
  534.     LONG ClickColumn (void) const
  535.     {
  536.          return (LONG)GetAttr (MUIA_Listview_ClickColumn);
  537.     }
  538.  
  539.     LONG DefClickColumn (void) const
  540.     {
  541.          return (LONG)GetAttr (MUIA_Listview_DefClickColumn);
  542.     }
  543.  
  544.     void SetDefClickColumn (LONG value)
  545.     {
  546.          SetAttr (MUIA_Listview_DefClickColumn, (ULONG)value);
  547.     }
  548.  
  549.     BOOL DoubleClick (void) const
  550.     {
  551.          return (BOOL)GetAttr (MUIA_Listview_DoubleClick);
  552.     }
  553.  
  554.     LONG DragType (void) const
  555.     {
  556.          return (LONG)GetAttr (MUIA_Listview_DragType);
  557.     }
  558.  
  559.     void SetDragType (LONG value)
  560.     {
  561.          SetAttr (MUIA_Listview_DragType, (ULONG)value);
  562.     }
  563.  
  564.     Object * List (void) const
  565.     {
  566.          return (Object *)GetAttr (MUIA_Listview_List);
  567.     }
  568.  
  569.     BOOL SelectChange (void) const
  570.     {
  571.          return (BOOL)GetAttr (MUIA_Listview_SelectChange);
  572.     }
  573. };
  574.  
  575.  
  576. #endif          /* MUIPP_TEMPLATES */
  577.  
  578. #endif          /* LIBRARIES_MUI_HPP */